package kr.saeildamil.androidStudy_second.actionbar;

import kr.saeildamil.androidStudy_second.MainActivity;
import kr.saeildamil.androidStudy_second.R;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class ACtionBarTest extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch21_actionbartest);
	}

	public void mOnClick(View v) {
		switch (v.getId()) {
		case R.id.ch21_actionbar_hide:
			ActionBar ab = getActionBar();
			if (ab.isShowing()) {
				ab.hide();
				((Button) v).setText("Show Action Bar");
			} else {
				ab.show();
				((Button) v).setText("Hide Action Bar");
			}

			break;
		case R.id.ch21_actionbar_top:
			break;
		case R.id.ch21_actionbar_bottom:
			break;
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.item1:
			Toast.makeText(this, "item1 Selected", Toast.LENGTH_LONG).show();
		case R.id.item2:
			Toast.makeText(this, "item2 Selected", Toast.LENGTH_LONG).show();
		case R.id.item3:
			Toast.makeText(this, "item3 Selected", Toast.LENGTH_LONG).show();
		case R.id.item4:
			Toast.makeText(this, "item4 Selected", Toast.LENGTH_LONG).show();
		case R.id.item5:
			Toast.makeText(this, "item5 Selected", Toast.LENGTH_LONG).show();
		case R.id.item6:
			Toast.makeText(this, "item6 Selected", Toast.LENGTH_LONG).show();
		case android.R.id.home:
			Toast.makeText(this, "logo icon Selected", Toast.LENGTH_LONG)
					.show();
			Intent intent = new Intent(this, MainActivity.class);
			intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(intent);
			return true;

		}
		return false;
	}
}
